// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   OrderCancelReviewScrPanel.java

package com.boci.clientapp.orderstatus;

import com.boci.clientapp.main.ClientAppLoader;
import com.boci.clientapp.orderstatus.action.OrderCancelAction;
import com.boci.clientapp.orderstatus.vo.OrderDetailVO;
import com.boci.clientapp.orderstatus.vo.OrderStatusDetailVO;
import com.boci.common.constant.ClientAppConst;
import com.boci.common.ui.AbstractPanel;
import com.boci.common.util.*;
import com.boci.common.vo.ResponseVO;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Locale;
import javax.swing.*;
import javax.swing.event.TableModelEvent;

public class OrderCancelReviewScrPanel extends AbstractPanel
{

    public OrderCancelReviewScrPanel(Locale pLocale, String pModuleName, String pScreenName)
    {
        super(pLocale, pScreenName, pScreenName);
        msgConf = ClientAppLoader.getMessagesConfigurator();
        initGUI();
        setText(pLocale);
    }

    public void setText(Locale pLocale)
    {
        super.setText(pLocale);
        setFont(pLocale);
        currentLocale = pLocale;
        lblReference.setText(msgConf.getUIMessages("ORDER_STATUS.REFERENCE_NO", pLocale));
        lblPalceOn.setText(msgConf.getUIMessages("ORDER_STATUS.PLACED_ON", pLocale));
        lblDuration.setText(msgConf.getUIMessages("ORDER_STATUS.DURATION", pLocale));
        lblOrderType.setText(msgConf.getUIMessages("ORDER_STATUS.ORDER_TYPE", pLocale));
        lblPrice.setText(msgConf.getUIMessages("ORDER_STATUS.PRICE", pLocale));
        lblQuantity.setText(msgConf.getUIMessages("ORDER_STATUS.QUANTITY", pLocale));
        lblTransaction.setText(msgConf.getUIMessages("ORDER_STATUS.TRANSACTION", pLocale));
        lblSecurityCode.setText(msgConf.getUIMessages("ORDER_STATUS.CODE", pLocale));
        lblNameOfSecurity.setText(msgConf.getUIMessages("ORDER_STATUS.NAME", pLocale));
        lbltitle.setText(msgConf.getUIMessages("ORDER_STATUS.CANCEL_ORDER", pLocale));
        btnYes.setText(msgConf.getUIMessages("ORDER_STATUS.YES", pLocale));
        btnNo.setText(msgConf.getUIMessages("ORDER_STATUS.NO", pLocale));
        String strTmp = msgConf.getUIMessages("ORDER_STATUS.ORDER_CANCEL_REV_1", pLocale);
        String strTmp3 = msgConf.getUIMessages("ORDER_STATUS.ORDER_CANCEL_REV_3", pLocale);
        lblCancelReviewMessage1.setText(strTmp);
        strTmp = msgConf.getUIMessages("ORDER_STATUS.ORDER_CANCEL_REV_2", pLocale);
        strTmp = strTmp.trim().length() != 0 ? (new StringBuilder()).append(strTmp).append(" ").append(strTmp3).toString() : strTmp3;
        lblCancelReviewMessage2.setText(strTmp);
        if(orderDetailVO != null)
            refresh(orderDetailVO);
        else
        if(orderStatusDetailVO != null)
            refresh(orderStatusDetailVO);
    }

    private void setFont(Locale pLocale)
    {
        lbltitle.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblReference.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblPalceOn.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblDuration.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblOrderType.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblPrice.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblQuantity.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblTransaction.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblSecurityCode.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblNameOfSecurity.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblReferenceValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblPlaceOnValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblDurationValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblOrderTypeValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblPriceValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblQualityValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblTransactionValue.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblSecurityCodeValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        lblNameOfSecurityValue.setFont(ClientAppLoader.getLargePlainTextFont(pLocale));
        btnYes.setFont(ClientAppLoader.getPlainButtonFont(pLocale));
        btnNo.setFont(ClientAppLoader.getPlainButtonFont(pLocale));
        lblCancelReviewMessage1.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
        lblCancelReviewMessage2.setFont(ClientAppLoader.getLargeBoldTextFont(pLocale));
    }

    public void initGUI()
    {
        setPreferredSize(new Dimension(710, 210));
        setBackground(Color.WHITE);
        setLayout(null);
        lblReferenceValue = new JLabel();
        lblReferenceValue.setBounds(145, 174, 160, 20);
        add(lblReferenceValue);
        lblReference = new JLabel();
        lblReference.setHorizontalAlignment(4);
        lblReference.setBounds(10, 174, 120, 20);
        add(lblReference);
        lblPalceOn = new JLabel();
        lblPalceOn.setHorizontalAlignment(4);
        lblPalceOn.setBounds(10, 155, 120, 20);
        add(lblPalceOn);
        lblPlaceOnValue = new JLabel();
        lblPlaceOnValue.setBounds(145, 155, 160, 20);
        add(lblPlaceOnValue);
        lblDurationValue = new JLabel();
        lblDurationValue.setBounds(145, 136, 160, 20);
        add(lblDurationValue);
        lblDuration = new JLabel();
        lblDuration.setHorizontalAlignment(4);
        lblDuration.setBounds(10, 136, 120, 20);
        add(lblDuration);
        lblOrderType = new JLabel();
        lblOrderType.setHorizontalAlignment(4);
        lblOrderType.setBounds(10, 117, 120, 20);
        add(lblOrderType);
        lblOrderTypeValue = new JLabel();
        lblOrderTypeValue.setBounds(145, 117, 160, 20);
        add(lblOrderTypeValue);
        lblPriceValue = new JLabel();
        lblPriceValue.setBounds(145, 98, 160, 20);
        add(lblPriceValue);
        lblPrice = new JLabel();
        lblPrice.setHorizontalAlignment(4);
        lblPrice.setBounds(10, 98, 120, 20);
        add(lblPrice);
        lblQuantity = new JLabel();
        lblQuantity.setHorizontalAlignment(4);
        lblQuantity.setBounds(10, 79, 120, 20);
        add(lblQuantity);
        lblQualityValue = new JLabel();
        lblQualityValue.setBounds(145, 79, 160, 20);
        add(lblQualityValue);
        lblTransactionValue = new JLabel();
        lblTransactionValue.setForeground(Color.BLUE);
        lblTransactionValue.setBounds(145, 60, 160, 20);
        add(lblTransactionValue);
        lblTransaction = new JLabel();
        lblTransaction.setHorizontalAlignment(4);
        lblTransaction.setBounds(10, 60, 120, 20);
        add(lblTransaction);
        lblSecurityCode = new JLabel();
        lblSecurityCode.setHorizontalAlignment(4);
        lblSecurityCode.setBounds(10, 41, 120, 20);
        add(lblSecurityCode);
        lblSecurityCodeValue = new JLabel();
        lblSecurityCodeValue.setBounds(145, 41, 160, 20);
        add(lblSecurityCodeValue);
        lblNameOfSecurityValue = new JLabel();
        lblNameOfSecurityValue.setBounds(145, 22, 320, 20);
        add(lblNameOfSecurityValue);
        lblNameOfSecurity = new JLabel();
        lblNameOfSecurity.setHorizontalAlignment(4);
        lblNameOfSecurity.setBounds(10, 22, 120, 20);
        add(lblNameOfSecurity);
        lbltitle = new JLabel();
        lbltitle.setBounds(13, 1, 125, 20);
        add(lbltitle);
        btnYes = new JButton();
        btnYes.setMargin(new Insets(2, 2, 2, 2));
        btnYes.setBounds(380, 125, 120, 25);
        btnYes.setActionCommand("CANCEL_REVIEW_CONFIRM");
        btnYes.addActionListener(this);
        add(btnYes);
        btnNo = new JButton();
        btnNo.setMargin(new Insets(2, 2, 2, 2));
        btnNo.setBounds(520, 125, 120, 25);
        btnNo.setActionCommand("CANCEL_REVIEW_NO");
        btnNo.addActionListener(this);
        add(btnNo);
        lblCancelReviewMessage1 = new JLabel();
        lblCancelReviewMessage1.setBounds(325, 80, 396, 20);
        add(lblCancelReviewMessage1);
        lblCancelReviewMessage2 = new JLabel();
        lblCancelReviewMessage2.setBounds(325, 100, 396, 20);
        add(lblCancelReviewMessage2);
    }

    public void actionPerformed(ActionEvent e)
    {
        PerformanceLogger.startAppTimer();
        String strActionType = e.getActionCommand();
        OrderCancelAction orderCancelAction = new OrderCancelAction();
        orderCancelAction.doProcess(getInputValue(strActionType), strActionType);
        PerformanceLogger.stopAppTimer();
        PerformanceLogger.doLog((new StringBuilder()).append(getScreenName()).append(".").append(strActionType).toString());
    }

    public void refresh()
    {
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                btnYes.requestFocus();
            }
        }
);
    }

    public void refresh(ResponseVO pResponseVO)
    {
        if(pResponseVO == null)
        {
            lblReferenceValue.setText("");
            lblPlaceOnValue.setText("");
            lblDurationValue.setText("");
            lblOrderTypeValue.setText("");
            lblPriceValue.setText("");
            lblQualityValue.setText("");
            lblTransactionValue.setText("");
            lblSecurityCodeValue.setText("");
            lblNameOfSecurityValue.setText("");
        } else
        if(pResponseVO instanceof OrderDetailVO)
        {
            orderDetailVO = (OrderDetailVO)pResponseVO;
            orderStatusDetailVO = null;
            lblReferenceValue.setText(StringUtil.getReferenceNo(orderDetailVO.getOrderId()));
            String strPlaceOnDate = orderDetailVO.getPlacementDate();
            strPlaceOnDate = StringUtil.formatLastUpdatedDateTime(orderDetailVO.getPlacementDate());
            strPlaceOnDate = strPlaceOnDate != null ? strPlaceOnDate : "";
            lblPlaceOnValue.setText(strPlaceOnDate);
            lblDurationValue.setText(msgConf.getUIMessages(orderDetailVO.getOrderDuration(), currentLocale));
            lblOrderTypeValue.setText(msgConf.getUIMessages(orderDetailVO.getOrderType(), currentLocale));
            if(isNoPriceOrderType(orderDetailVO.getOrderType()))
                lblPriceValue.setVisible(false);
            else
                lblPriceValue.setVisible(true);
            String strCcy = msgConf.getUIMessages(orderDetailVO.getCurrency(), currentLocale);
            String strPrice = StringUtil.formatPriceValue(orderDetailVO.getPrice(), strCcy);
            String strTempQty = orderDetailVO.getOrderQuantity();
            if(strTempQty == null || strTempQty.length() == 0)
                strTempQty = orderDetailVO.getOriginalQuantity();
            String strQty = StringUtil.formatQtyValue(strTempQty);
            lblPriceValue.setText(strPrice);
            lblQualityValue.setText(strQty);
            String strBuyOrSell = orderDetailVO.getBuyOrSell();
            if(strBuyOrSell.equalsIgnoreCase("BUY"))
                lblTransactionValue.setForeground(Color.BLUE);
            else
            if(strBuyOrSell.equalsIgnoreCase("SELL"))
                lblTransactionValue.setForeground(Color.RED);
            lblTransactionValue.setText(msgConf.getUIMessages(strBuyOrSell, currentLocale));
            lblSecurityCodeValue.setText(orderDetailVO.getSymbol());
            String strNameEng = orderDetailVO.getName();
            String strNameChs = orderDetailVO.getName_chs();
            String strNameChi = orderDetailVO.getName_chi();
            if(currentLocale.equals(ClientAppConst.ZH_HK) && strNameChi != null && strNameChi.length() != 0)
                lblNameOfSecurityValue.setText(strNameChi);
            else
            if(currentLocale.equals(ClientAppConst.ZH_CN) && strNameChs != null && strNameChs.length() != 0)
                lblNameOfSecurityValue.setText(strNameChs);
            else
                lblNameOfSecurityValue.setText(strNameEng);
        } else
        if(pResponseVO instanceof OrderStatusDetailVO)
        {
            orderStatusDetailVO = (OrderStatusDetailVO)pResponseVO;
            orderDetailVO = null;
            lblReferenceValue.setText(StringUtil.getReferenceNo(orderStatusDetailVO.getOrderId()));
            String strPlaceOnDate = orderStatusDetailVO.getPlacementDate();
            strPlaceOnDate = StringUtil.formatLastUpdatedDateTime(orderStatusDetailVO.getPlacementDate());
            strPlaceOnDate = strPlaceOnDate != null ? strPlaceOnDate : "";
            lblPlaceOnValue.setText(strPlaceOnDate);
            lblDurationValue.setText(msgConf.getUIMessages(orderStatusDetailVO.getOrderDuration(), currentLocale));
            lblOrderTypeValue.setText(msgConf.getUIMessages(orderStatusDetailVO.getOrderType(), currentLocale));
            if(isNoPriceOrderType(orderStatusDetailVO.getOrderType()))
                lblPriceValue.setVisible(false);
            else
                lblPriceValue.setVisible(true);
            String strCcy = msgConf.getUIMessages(orderStatusDetailVO.getCurrency(), currentLocale);
            String strPrice = StringUtil.formatPriceValue(orderStatusDetailVO.getPrice(), strCcy);
            lblPriceValue.setText(strPrice);
            String strTempQty = orderStatusDetailVO.getOrderQuantity();
            if(strTempQty == null || strTempQty.length() == 0)
                strTempQty = orderStatusDetailVO.getOriginalQuantity();
            String strQty = StringUtil.formatQtyValue(strTempQty);
            lblQualityValue.setText(strQty);
            String strBuyOrSell = orderStatusDetailVO.getBuyOrSell();
            if(strBuyOrSell.equalsIgnoreCase("BUY"))
                lblTransactionValue.setForeground(Color.BLUE);
            else
            if(strBuyOrSell.equalsIgnoreCase("SELL"))
                lblTransactionValue.setForeground(Color.RED);
            lblTransactionValue.setText(msgConf.getUIMessages(strBuyOrSell, currentLocale));
            lblSecurityCodeValue.setText(orderStatusDetailVO.getSymbol());
            String strNameEng = orderStatusDetailVO.getName();
            String strNameChs = orderStatusDetailVO.getName_chs();
            String strNameChi = orderStatusDetailVO.getName_chi();
            if(currentLocale.equals(ClientAppConst.ZH_HK) && strNameChi != null && strNameChi.length() != 0)
                lblNameOfSecurityValue.setText(strNameChi);
            else
            if(currentLocale.equals(ClientAppConst.ZH_CN) && strNameChs != null && strNameChs.length() != 0)
                lblNameOfSecurityValue.setText(strNameChs);
            else
                lblNameOfSecurityValue.setText(strNameEng);
        }
    }

    public HashMap getInputValue(String pActionType)
    {
        HashMap map = new HashMap();
        if(orderDetailVO != null)
            map.put("SELECTED_VO", orderDetailVO);
        else
        if(orderStatusDetailVO != null)
            map.put("SELECTED_VO", orderStatusDetailVO);
        return map;
    }

    public boolean validate(String pActionType)
    {
        return true;
    }

    public void tableChanged(TableModelEvent tablemodelevent)
    {
    }

    public void setDefFocus()
    {
        SwingUtilities.invokeLater(new Runnable() {

            public void run()
            {
                btnYes.requestFocus();
            }
        }
);
    }

    private boolean isNoPriceOrderType(String pOrderType)
    {
        boolean returnFlag = false;
        String strNoPriceTypes[] = ClientAppLoader.getNoPriceOrdTypes();
        int i = 0;
        do
        {
            if(i >= strNoPriceTypes.length)
                break;
            if(strNoPriceTypes[i].equals(pOrderType))
            {
                returnFlag = true;
                break;
            }
            i++;
        } while(true);
        return returnFlag;
    }

    private JLabel lbltitle;
    private JLabel lblNameOfSecurity;
    private JLabel lblNameOfSecurityValue;
    private JLabel lblSecurityCodeValue;
    private JLabel lblSecurityCode;
    private JLabel lblTransaction;
    private JLabel lblTransactionValue;
    private JLabel lblQualityValue;
    private JLabel lblQuantity;
    private JLabel lblPrice;
    private JLabel lblPriceValue;
    private JLabel lblOrderTypeValue;
    private JLabel lblOrderType;
    private JLabel lblDuration;
    private JLabel lblDurationValue;
    private JLabel lblPlaceOnValue;
    private JLabel lblPalceOn;
    private JLabel lblReference;
    private JLabel lblReferenceValue;
    private JLabel lblCancelReviewMessage2;
    private JLabel lblCancelReviewMessage1;
    private JButton btnNo;
    private JButton btnYes;
    private Locale currentLocale;
    private MessagesConfigurator msgConf;
    private OrderDetailVO orderDetailVO;
    private OrderStatusDetailVO orderStatusDetailVO;

}
